package parallel.project.solver;

import parallel.project.framework.MazeException;
import parallel.project.framework.Mazemap;
import parallel.project.graph.*;

/**
 * 
 * 
 * @author Adam Clayton
 * @author Larry Walters
 */
public interface SolverMaster extends Runnable, 
	SlaveNotificationListener
{
	/**
	 * Requests that the given slave be stopped.
	 * 
	 * @param slave
	 * 		{@link SolverSlave} to stop
	 */
	public void killSlave(SolverSlave slave);
	
	/**
	 * Starts the graph creation process on the given maze, taking the 
	 * requested numeral into account.  This given "number of slaves" 
	 * can define either how many slaves to use, or the maximum that 
	 * can be used, depending on the algorithm.
	 * 
	 * @param num
	 * 		Number of {@link SolverSlaves}
	 * @param maze
	 * 		Maze to convert to a {@link Graph}
	 */
	public void startSolvers(int num, Mazemap maze) throws MazeException;
}

///**
// * Defines a master object which handles the starting and stopping of
// * solving slave threads (started as {@link SolverSlave}s) on a given
// * {@link Graph}.  Slaves notify this master where they are and what
// * path they are proceeding on, and the master uses that info to 
// * determine whether more slaves need to be made at certain locations
// * or if slaves should be killed.
// * 
// * @author Adam Clayton
// * @author Larry Walters
// */
//public interface SolverMaster extends Runnable, 
//	SlaveNotificationListener
//{
//	/**
//	 * Requests that the given slave be stopped.
//	 * 
//	 * @param slave
//	 * 		{@link SolverSlave} to stop
//	 */
//	public void killSlave(SolverSlave slave);
//	
//	/**
//	 * Alerts this master that the given slave has arrived at the 
//	 * given {@link Node}, and is now going to follow the given 
//	 * {@link Edge} from that {@link Node} to whichever other one it
//	 * goes to.  If the {@link Edge} is null that means it is unsure
//	 * what to do.
//	 * 
//	 * @param slave
//	 * 		{@link SolverSlave} that is sending this notification
//	 * @param n
//	 * 		The {@link Node} the {@link SolverSlave} is at
//	 * @param edge
//	 * 		The {@link Edge} the slave is now going to follow, or null
//	 * 		if it is not sure what to do
//	 */
//	public void notifyLocation(SolverSlave slave, Node at, Edge going);
//	
//	/**
//	 * Notifies this master that the given slave has arrived at an end
//	 * destination in the maze, meaning it has solved it.
//	 * 
//	 * @param slave
//	 * 		{@link SolverSlave} that is sending this notification
//	 * @param end
//	 * 		The {@link Node} that the {@link SolverSlave} ended at
//	 */
//	public void solved(SolverSlave slave, Node end);
//	
//	/**
//	 * Requests that a new {@link SolverSlave} be started at the given
//	 * {@link Node} traversing the given {@link Edge}.
//	 * 
//	 * @param start
//	 * 		Starting {@link Node} location
//	 * @param traverse
//	 * 		The {@link Edge} which links the start {@link Node} to 
//	 * 		another {@link Node}, and that other {@link Node} is where
//	 * 		the {@link SolverSlave} will be traveling to.
//	 */
//	public void startSlave(Node start, Edge traverse);
//	
//	/**
//	 * Starts the solving process on the given {@link Graph}, taking
//	 * the requested numeral into account.  This given "number of 
//	 * slaves" can define either how many slaves to use, or the 
//	 * maximum that can be used, depending on the solving algorithm.
//	 * 
//	 * @param num
//	 * 		Number of {@link SolverSlaves}
//	 * @param graph
//	 * 		{@link Graph} to solve
//	 */
//	public void startSolvers(int num, Graph graph);
//}
